$(function() {
    var scrollWidth='0';
    var p=0,
        t=0;

    var scrollW=-$(this).scrollTop();
    $('.scroll-content').css('transform','translate('+scrollW+'px, 0)')
    //获取class等于f1的宽
    /*var newObj=$(".product-feature").childNodes;
  alert(newObj);*/
    var newObj = $('.product-feature').children().length-1;
    var f1width=$('.f6').width()*newObj;
    $('.scroll-container-vertical').css('height',f1width)
    document.getElementById("box2").className="";


    window.onscroll=function(){
        p=$(this).scrollTop();

        if(t<p){

            //下滚
            scrollWidth=-$(this).scrollTop();
            $('.scroll-content').css('transform','translate('+scrollWidth+'px, 0)')
        }else{

            //上滚
            scrollWidth=-$(this).scrollTop();
            $('.scroll-content').css('transform','translate('+scrollWidth+'px, 0)')
        }

        setTimeout(function(){ t = p ; },0)

    }

    window.onresize=function(){
        var scrollW=-$(this).scrollTop();
        $('.scroll-content').css('transform','translate('+scrollW+'px, 0)')
        //获取class等于f1的宽
        /*var newObj=$(".product-feature").childNodes;
      alert(newObj);*/
        var newObj = $('.product-feature').children().length-1;
        var f1width=$('.f6').width()*newObj;
        $('.scroll-container-vertical').css('height',f1width)
        document.getElementById("box2").className="";
    }

  /*  // logo移动切换
    $(".header .logo").hover(function() {
        //页面加载的时候显示的图片
        $(this).css("background-image", "url(img/logo.png)");
    }, function() {

        if($(".language").css("display") == "block"){
            $(this).css("background-image", "url(images/logo_gray.png)");
        }else{
            $(this).css("background-image", "url(images/logo.png)");
        }

        if($(".header .submenu").css("top") == '0px'){
            $(this).css("background-image", "url(images/logo_gray.png)");
        }else{
            $(this).css("background-image", "url(images/logo.png)");
        }

    })*/

    // 幻灯片播放
    $("#slider").responsiveSlides({
        auto: true,
        pager: false,
        nav: true,
        speed: 500,
        timeout: 4000,
        pager: true,
        pauseControls: true,
        namespace: "callbacks"
    });

    // 打开下拉菜单
    $(".header .nav li:lt(4)").mouseenter(function(){
//		$(".header").css("background-color", "transparent");
        /*$(".header .logo").css("background-image", "url(img/logo_gray.png)");*/
        $(".header .nav li:eq(7)").find("img").attr("src","images/so_active_ico.png");
        $(".header .language_switch").css({
            "position": "relative",
            "z-index": 9,
            "color": "#666",
            "background-image": "url(images/lang_active.png)"
        })

        $(this).siblings().find("h2 a").css("color", "#000");
        $(this).find("h2 a").css("color", "#0f9af2");
        $(".header .submenu").animate({
            top: '-15px'
        }, "fast");
        $(".header .submenu dl").eq($(this).index()).animate({
            top: '0px'
        }, "fast").siblings().animate({
            top: "-600px"
        }, 50);
    })

    // 收起下拉菜单
    $(".header").mouseleave(function(){
//		$(".header").css("background-color", "#141414");
        /*$(".header .logo").css("background-image", "url(img/logo.png)");*/
        $(".header .nav li:eq(7)").find("img").attr("src","images/so_ico.png");

        $(this).siblings().find("h2 a").css("color", "#000");
        $(this).find("h2 a").css("color", "#000");
        $(".header .submenu").animate({
            top: "-600px"
        }, "fast");
        $(".header .submenu dl").eq($(this).index()).animate({
            top: "-600px"
        }, "fast");
    })

    // 移动到后两个按钮收起
    $(".header .nav li:eq(1),.header .nav li:eq(2)").mouseenter(function(){
//		$(".header").css("background-color", "#141414");
        /*$(".header .logo").css("background-image", "url(img/logo.png)");*/
        $(".header .nav li:eq(7)").find("img").attr("src","images/so_ico.png");

        $(this).siblings().find("h2 a").css("color", "#000");
        $(this).find("h2 a").css("color", "#0f9af2");
        $(".header .submenu").animate({
            top: "-600px"
        }, 10);
        $(".header .submenu dl").eq($(this).index()).animate({
            top: "-600px"
        }, 10);
    });
    // 滚动到顶部
    $(window).scroll(function() {
        if($(window).scrollTop() > 100) {
            $("#backTop").fadeIn(500);
        } else {
            $("#backTop").fadeOut(500);
        }
    });
    $("#backTop").on("click", function() {
        $('body,html').animate({
            scrollTop: 0
        }, 200);
        return false;
    });
    // 详情页锚点信息链接
    $(".nav1,.nav2").click(function(){

        var cl = $(this).attr("class");
        if(cl=='nav1'){
            var scrleft=0;
        }else{
            var scrleft=$('.f6').width()*5;
        }
        $('html,body').animate({scrollTop: scrleft}, 500);
    })
    function aa(){
        alert('fd');
    }

});